//
//  HopeMoneyViewController.m
//  u76ho
//
//  Created by m-air-01 on 16/1/11.
//  Copyright © 2016年 LV. All rights reserved.
//

#import "HopeMoneyViewController.h"
#import "PositionModel.h"
@interface HopeMoneyViewController ()
<UITableViewDataSource,UITableViewDelegate>
{
    UITableView * _tableView;
    NSMutableArray * _dataSource;
}
@end

@implementation HopeMoneyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self main];
    self.navigationItem.title = @"期望月薪";
  //  [self addBackItem];
   // [self addNavgationBar];
    // Do any additional setup after loading the view.
}
-(void)main
{
    _dataSource = [[NSMutableArray alloc]init];
//    [_dataSource addObjectsFromArray:@[@"2k以下",@"2k-5k",@"5k-10k",@"10k-15k",@"15k-25k",@"25k-50k",@"50k以上"]];
    
    self.view.backgroundColor = UIColorFromRGB(0xf1f3f2);
    _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT-64) style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [self.view addSubview:_tableView];
    self.automaticallyAdjustsScrollViewInsets = NO;
    [self requestData];
}
-(void)requestData
{
    [U76HONet selectedTypeReadWithtype:@"8" fid:@"0" code:@"0" andDataBlock:^(NSArray *arr) {
        NSLog(@"职位分类获取数据成功了");
        [_dataSource addObjectsFromArray:arr];
        [_tableView reloadData];
    }];
    
}
#pragma mark - _tableViewDelegate
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _dataSource.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString * ID = @"cell";
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    PositionModel * model = _dataSource[indexPath.row];
    cell.textLabel.text = model.typenames;
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    PositionModel * model = _dataSource[indexPath.row];
    [self.delegate choseHopeMoneywithStr:model.typenames andHopemoneyId:model.Ids];
    [self.navigationController popViewControllerAnimated:YES];
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}
#pragma  mark - 返回按钮图标
-(void)addBackItem{
    UIButton * backItem = [UIButton buttonWithType:UIButtonTypeCustom];
    backItem.frame = CGRectMake(0, 0, 9, 17);
    [backItem setImage:[UIImage imageNamed:@"返回图标"] forState:UIControlStateNormal];
    [backItem addTarget:self action:@selector(backItem:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:backItem];
}
-(void)backItem:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
